package com.zero.yygh.hosp.controller;

import com.zero.yygh.common.result.Result;
import com.zero.yygh.hosp.service.HospitalService;
import com.zero.yygh.model.hosp.Hospital;
import com.zero.yygh.vo.hosp.HospitalQueryVo;
import com.zero.yygh.vo.hosp.HospitalSetQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author zero
 * @desc 医院信息
 * @create 2021/3/28
 */
@Api("医院管理")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Resource
    private HospitalService hospitalService;

    @ApiOperation("分页查询医院列表")
    @GetMapping("list/{page}/{limit}")
    public Result<Page<Hospital>> listHosp(@PathVariable Integer page, @PathVariable Integer limit, HospitalQueryVo hospitalQueryVo) {
        return Result.ok(hospitalService.selectHospPage(page, limit, hospitalQueryVo));
    }

    @ApiOperation(value = "更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result<String> lock(
            @ApiParam(name = "id", value = "医院id", required = true)
            @PathVariable("id") String id,
            @ApiParam(name = "status", value = "状态（0：未上线 1：已上线）", required = true)
            @PathVariable("status") Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    @ApiOperation(value = "获取医院详情")
    @GetMapping("show/{id}")
    public Result<Map<String, Object>> show(
            @ApiParam(name = "id", value = "医院id", required = true)
            @PathVariable String id) {
        return Result.ok(hospitalService.show(id));
    }

}
